import {
	MessageConstant
} from "zpub_http/constant/MessageConstant.js"
import {
	WhatConstant
} from "zpub_http/constant/WhatConstant.js"
import {
	HttpParamKeyValue
} from "zpub_svr/constant/HttpParamKeyValue.js"
import {
	HttpProtocol
} from "zpub_http/http/HttpProtocol.js"
import {
	BaseService
} from "zpub_http/service/BaseService.js"
import {
	MajorMinorBusiness
} from "../../constant/MajorMinorBusiness.js"
import {
	FldValueBusiness
} from "../../constant/FldValueBusiness.js"
import {
	MajorMinorConstant
} from "zpub_db/constant/MajorMinorConstant.js"
import {
	DateUtil
} from "../../util/DateUtil.js"

/*
 * 功能：评价服务模块
 * 需要传入的键：
 * 传入的值类型：
 * 传入的值含义：
 * 是否必传 ：
 * 作者：郑朝军 on 2019/4/7 23:23
 * 邮箱：1250393285@qq.com
 * 公司：武汉智博创享科技有限公司
 */
class PJService extends BaseService {
	/*
	 * 查询属性<br/>
	 */
	static queryPJ(shopID, listener) {
		listener.showLoading({
			title: '正在查询评价表'
		});
		let protocol = new HttpProtocol();
		protocol
			.setService('SvrPubQueryControl')
			.setMethod('queryForFieldValuesExp')
			.addParam(HttpParamKeyValue.PARAM_KEY_MAJOR, MajorMinorBusiness.MAJOR_BUSINESS)
			.addParam(HttpParamKeyValue.PARAM_KEY_MINOR, MajorMinorBusiness.MINOR_SHOP_PJ)
			.addParam('exp', " shopid = " + shopID)
			.post().then((data) => {
				let jo = this.responseData(data);
				if (this.isDataInvalid("queryPJ", jo, listener)) {
					return MessageConstant.MSG_EMPTY;
				}
				let map = {data:[],size:0};

				let time = DateUtil.dataFormatsFull(data.result[0].time);
				data.result[0].time = time;
				
				// 设置数据
				map.data.push(data.result[0]);
				map.size = data.result.length;
				this.sendMessage("queryPJ", map, WhatConstant.WHAT_NET_DATA_SUCCESS, listener);
			})
			.catch((err) => {
				this.sendMessage("queryPJ", err, WhatConstant.WHAT_NET_DATA_FAIL, listener);
			});
	}
}

export {
	PJService
}
